package com.inspire.tank.strategy;

import com.inspire.tank.*;
import com.inspire.tank.decorator.RectDecorator;
import com.inspire.tank.decorator.TailDecorator;

/**
 * @author inspire
 * @description
 * @date 2022/6/5 22:40
 */
public class FourDirFireStrategy implements FireStrategy{
    public void fire(Tank t) {
        int bX=t.x+Tank.WIDTH/2-Bullet.WIDTH/2;
        int bY=t.y+Tank.HEIGHT/2-Bullet.HEIGHT/2;
        Dir[] dirs=Dir.values();

        for(Dir dir:dirs){
            //装饰器模式
            //BUG bullet将自己又加了一遍
            //GameModel.getInstance().add(new RectDecorator(new TailDecorator(new Bullet(bX,bY,dir,t.group))));
            new Bullet(bX,bY,dir,t.group);
        }

        /*if(t.group == Group.GOOD){
            new Thread(()->new Audio("D:\\dev_file\\Git_file\\tank\\src\\audio\\tank_fire.wav").loop()).start();
        }*/

    }
}
